// 页面中类型定义

export interface ResData<T> {
  code: number
  message: string
  data: T
}

/**
 * 通用表单数据接口，用于与后端API交互
 */
export interface FormData {
  id?: string
  name: string
  code?: string | null | undefined
  toCode?: string | null | undefined
  type: number
  status?: 'ACTIVE' | 'INACTIVE' | null // status 为枚举类型
  pid?: string | null
  level?: number
  sort?: number | null
  createAt?: string
  updateAt?: string
}

/** 权限/菜单项（树） */
export interface PermissionItem {
  id: string
  pid?: string
  name: string
  code?: string | null | undefined
  toCode?: string | null | undefined
  type: number
  status?: 'ACTIVE' | 'INACTIVE' | null // status 为枚举类型
  level?: number
  createdAt?: string
  updatedAt?: string
  children?: PermissionItem[]
}

export type ResPermissionTree = ResData<PermissionItem[]>

/** 分配角色接口返回的数据体 */
export interface AssignRoleData {
  allRolesList: unknown[]
  assignRoles: unknown[]
}

export type ResAssignRoleData = ResData<AssignRoleData>

// 定义搜索参数类型，避免与 Record 接口命名冲突
export type SearchParams = { [key: string]: unknown }

export interface Pagination {
  current: number
  pages: number
  size: number
  total: number
}

// pagelist 接口 - 使用RoleItem类型以避免与Record接口冲突
export interface PageList {
  records: PermissionItem[]
  searchCount: boolean
  size: number
  total: number
  current: number
  pages?: number
}

export type ResPageList = ResData<PageList>
